package org.lds.hotkey.console.business.currhotkey.controller;

import lombok.extern.slf4j.Slf4j;
import org.lds.hotkey.common.model.dto.ResultDTO;
import org.lds.hotkey.common.model.pojo.OrderBy;
import org.lds.hotkey.common.model.pojo.PageResult;
import org.lds.hotkey.console.business.currhotkey.model.request.*;
import org.lds.hotkey.console.business.currhotkey.model.response.*;
import org.lds.hotkey.console.business.currhotkey.service.CurrHotKeyBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *  基础前端控制器
 *
 * @author lidongsheng
 * @since 2024-07-15
 */
@Slf4j
@RestController
@RequestMapping("/api/common/currHotKey")
public class CurrHotKeyBaseController {

    @Autowired
    private CurrHotKeyBaseService currHotKeyBaseService;

    /**
    * 创建
    */
    @PostMapping("/create")
    public ResultDTO<CurrHotKeyBaseResponse> createCurrHotKey(@RequestBody @Validated CurrHotKeyBaseCreateRequest request) {
         return currHotKeyBaseService.createCurrHotKey(request); 
    }
 
    /**
    * 批量创建
    */
    @PostMapping("/batch-create")
    ResultDTO<CurrHotKeyBaseBatchCreateResponse> batchCreateCurrHotKey(@RequestBody @Validated CurrHotKeyBaseBatchCreateRequest request) {
        return currHotKeyBaseService.batchCreateCurrHotKey(request);
    }

    /**
    * 删除
    */
    @PostMapping("/delete")
    ResultDTO<CurrHotKeyBaseDeleteResponse> deleteCurrHotKey(@RequestBody CurrHotKeyBaseDeleteRequest request) {
        return currHotKeyBaseService.deleteCurrHotKey(request);
    }

    /**
    * 批量删除
    */
    @PostMapping("/batch-delete")
    ResultDTO<CurrHotKeyBaseBatchDeleteResponse> batchDeleteCurrHotKey(@RequestBody @Validated CurrHotKeyBaseBatchDeleteRequest request) {
        return currHotKeyBaseService.batchDeleteCurrHotKey(request);
    }

    /**
    * 更新
    */
    @PostMapping("/update")
    ResultDTO<CurrHotKeyBaseResponse> updateCurrHotKey(@RequestBody @Validated CurrHotKeyBaseUpdateRequest request) {
        return currHotKeyBaseService.updateCurrHotKey(request);
    }

    /**
    * 批量更新
    */
    @PostMapping("/batch-update")
    ResultDTO<CurrHotKeyBaseBatchUpdateResponse> batchUpdateCurrHotKey(@RequestBody @Validated CurrHotKeyBaseBatchUpdateRequest request) {
        return currHotKeyBaseService.batchUpdateCurrHotKey(request);
    }

    /**
    * 查询
    */
    @PostMapping("/list")
    ResultDTO<CurrHotKeyBaseListResponse> listCurrHotKey(@RequestBody CurrHotKeyBaseListRequest request) {
        return currHotKeyBaseService.listCurrHotKey(request);
    }

    /**
    * 查询所有
    */
    @PostMapping("/list-all")
    ResultDTO<CurrHotKeyBaseListResponse> listAllCurrHotKey(@RequestBody OrderBy orderBy) {
        return currHotKeyBaseService.listAllCurrHotKey(orderBy);
    }

    /**
    * 根据ID查询
    */
    @PostMapping("/get")
    ResultDTO<CurrHotKeyBaseResponse> getCurrHotKeyById(@RequestBody @Validated CurrHotKeyBaseGetByIdRequest request) {
        return currHotKeyBaseService.getCurrHotKeyById(request);
    }

    /**
    * 根据ID集合查询
    */
    @PostMapping("/gets")
    ResultDTO<CurrHotKeyBaseListResponse> getCurrHotKeyByIds(@RequestBody @Validated CurrHotKeyBaseGetByIdsRequest request) {
        return currHotKeyBaseService.getCurrHotKeyByIds(request);
    }
                                        
    /**
    * 分页查询
    */
    @PostMapping("/list-page")
    ResultDTO<PageResult<CurrHotKeyBaseResponse>> listCurrHotKeyPage(@RequestBody CurrHotKeyBaseListPageRequest request) {
        return currHotKeyBaseService.listCurrHotKeyPage(request);
    }

    /**
    * 业务主键对应数据是否存在
    */
    @PostMapping("/isExist")
    public ResultDTO<Boolean> isExist(@RequestBody @Validated CurrHotKeyBaseGetByKeyRequest request) {
        return ResultDTO.success(currHotKeyBaseService.getCurrHotKeyByKey(request) != null);
    }

    /**
    * 异步批量创建 - 慎用(并发不高可以无脑使用)
    */
    @PostMapping("/batch-create-async")
    ResultDTO<CurrHotKeyBaseBatchCreateResponse> batchCreateCurrHotKeyAsync(@RequestBody @Validated CurrHotKeyBaseBatchCreateRequest request) {
        return currHotKeyBaseService.batchCreateCurrHotKeyAsync(request);
    }

    /**
    * 异步批量删除 - 慎用(并发不高可以无脑使用)
    */
    @PostMapping("/batch-delete-async")
    ResultDTO<CurrHotKeyBaseBatchDeleteResponse> batchDeleteCurrHotKeyAsync(@RequestBody @Validated CurrHotKeyBaseBatchDeleteRequest request) {
        return currHotKeyBaseService.batchDeleteCurrHotKeyAsync(request);
    }

    /**
    * 异步批量更新 - 慎用(并发不高可以无脑使用)
    */
    @PostMapping("/batch-update-async")
    ResultDTO<CurrHotKeyBaseBatchUpdateResponse> batchUpdateCurrHotKeyAsync(@RequestBody @Validated CurrHotKeyBaseBatchUpdateRequest request) {
        return currHotKeyBaseService.batchUpdateCurrHotKeyAsync(request);
    }
           
}